package com.csw.scala

import scala.io.Source

object Demo25implicit {
  def main(args: Array[String]): Unit = {

    /**
      * 3、隐式转换类
      *
      * 可以自动将ReadFile构造函数参数的类型转换成ReadFile
      */
    val list: List[String] = "Scala/data/words.txt".read()
    list.foreach(println)

  }

  implicit class ReadFile(path: String) {
    def read() = {
      Source.fromFile(path).getLines().toList
    }
  }

}
